package lei.i_java的function接口;

/**
 * @className: Predicate
 * @author: xl
 * @date: 2025/3/1 15:42
 * @Version: 1.0
 * @description:
 */

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class PredicateExample {
    public static void main(String[] args) {
        List<String> languages = Arrays.asList("Java", "Python", "C++", "JavaScript");

        // 使用 Lambda 表达式过滤出长度大于 3 的字符串
        Predicate<String> predicate = lang -> lang.length() > 3;
        languages.stream()
                .filter(predicate)
                .forEach(System.out::println); // 输出: Java, Python, JavaScript
    }
}
